<%@page contentType="text/html" import="java.util.Collection, Bean.*"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/taglib139.tld" prefix="pg" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%
if(session.getAttribute("un")==null){
    response.sendRedirect("indexAdmin.jsp?page=Admin&url=Login");
    out.println("You must be login..!");
}else{%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script language="javascript" type="text/javascript" src="../script/validate.js"></script>
<script language="javascript">
    function kiemtra(){
        var id = document.form1.txtregid;
        var statu = document.form1.txtstatus;
        var date = document.form1.txtdate;
        if( laChuoiRong(id.value))
	{
            alert('Registration ID is not blank!');
            id.focus();
            return false;
	}
        if( laChuoiRong(statu.value))
	{
            alert('Status is not blank!');
            statu.focus();
            return false;
	}
        if( laChuoiRong(date.value))
	{
            alert('Date is not blank!');
            statu.focus();
            return false;
	}
       if(!laNgay(date.value))
            {
                alert('Date invail !');
                date.focus();
                return false;
            }
        return true;
    }
</script>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <% 
    String regid="";
    String rollno="";
    String scheid="";
    String status="";
    String date="";
    if(session.getAttribute("regid")!=null){
        regid=session.getAttribute("regid").toString();
        //rollno=session.getAttribute("rollno").toString();
        //scheid=session.getAttribute("scheid").toString();
        status=session.getAttribute("status").toString();
        date=session.getAttribute("date").toString();
    }
    
    %>
    
    
    <body>
        <% 
        ReRegistrationBean obj=new ReRegistrationBean();
        Collection kq=obj.getListReRegistration();
        request.setAttribute("st", kq);
        %>
        
        <%
        StudentBean ojb1=new StudentBean();
        Collection st=ojb1.getListStudent();
        request.setAttribute("ddl", st);
        %>
        
        <% 
        SchedulesBean obj2=new SchedulesBean();
        Collection regis=obj2.getListSchedules();
        request.setAttribute("regis", regis);
        %>
        <h3 align="center" >Registration Management (the re-evaluation or re-counting )</h3>
        <form method="POST" action="../ControllReRegistration" name="form1" onsubmit="return kiemtra()">
            <table>
                <tr>
                    <td>Reg ID</td>
                    <td><input type="text" name="txtregid" value="<%=regid%>" /><input type="hidden" name="txttempid" value="<%=regid%>" /></td>
                </tr>
                <tr>
                    <td>Roll no</td>
                    <td><select name="ddlrollno">
                            <c:forEach items="${ddl}" var="s">
                                <option value="${s.rollno}" >${s.rollno}</option>    
                            </c:forEach>
                            
                    </select></td>
                </tr>
                <tr>
                    <td>Sche ID</td>
                    <td><select name="ddlscheid">
                            <c:forEach items="${regis}" var="r">
                                <option value="${r.scheid}" >${r.scheid}</option>    
                            </c:forEach>
                            
                    </select></td>
                </tr>
                <tr>
                    <td>Status</td>
                    <td>
                        <select name="txtstatus">
                            <option value="Re-evaluation">Re-evaluation</option>
                            <option value="Re-counting">Re-counting</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Date</td>
                    <td><input type="text" name="txtdate" value="<%=date%>" /> (MM/dd/yyyy)</td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" value="Insert" name="bt" />
                        <input type="submit" value="Update" name="bt" />
                        <input type="button" value="Reset" name="bt"  onclick="clear_fields()" />
                    </td>
                    
                </tr>
            </table>
            <table border="1">
                <tr>
                    <th>RegID</th>
                    <th>Rollno</th>
                    <th>ScheID</th>
                    <th>Status</th>
                    <th>Date</th>
                    <th colspan="2">Action</th>
                </tr>
                <pg:paging pageSize="10" url="indexAdmin.jsp?page=Admin&url=user">
                    <c:forEach items="${st}" var="s">
                        <pg:item> 
                            <tr>
                                <td><c:out value="${s.regid}" /></td>
                                <td>${s.rollno}</td>
                                <td>${s.scheid}</td>
                                <td>${s.status}</td>
                                <td>${s.date}</td>
                                <c:url var="delete" value="../ControllReRegistration">
                                    <c:param name="bt" value="Delete" />
                                    <c:param name="regid" value="${s.regid}" />
                                    <c:param name="p" value="${param.pageNum}"/>
                                </c:url>
                                <c:url var="edit" value="../ControllReRegistration">
                                    <c:param name="bt" value="Edit" />
                                    <c:param name="regid" value="${s.regid}" />
                                    <c:param name="rollno" value="${s.rollno}" />
                                    <c:param name="scheid" value="${s.scheid}" />
                                    <c:param name="status" value="${s.status}" />
                                    <c:param name="date" value="${s.date}" />
                                    <c:param name="p" value="${param.pageNum}"/>
                                </c:url>
                                
                                <td><a href="${edit}">Edit</a></td>
                                <td><a href="${delete}" onclick="return confirm('Do you really want to delete these records ?')">Delete</a></td>
                                
                            </tr>
                        </pg:item>
                    </c:forEach>
                     <pg:index>
                            <pg:page><%=thisPage%></pg:page>
                            <pg:firstPage>[First]</pg:firstPage>
                            <pg:lastPage>[Last]</pg:lastPage> 
                        </pg:index> 
                </pg:paging>
            </table>
        </form>
    </body>
</html>
